﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using IFRS.DataAccess.DAL;
using System.Data;
using IFRS.Models;
using IFRS_Global;
using System.Globalization;

public partial class IFRS_WIN15_3V : PageBase
{
    #region "---------- Events -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack || Page.IsCallback))
        {
            this.ViewMenu();
            this.BindDLL();
            if (Request.QueryString["id"].ToString() != null)
            this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    #endregion

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN15_1S.aspx");
    }

    #region "----- Methods -------"

    private void ViewMenu()
    {
        this.MenuTitleBar = Resources.ifrsMenu.WIN15_3V;
    }
    private void BindDLL()
    {
        ddlSourceData.SetData(DDL_TYPE.SourceData, "", false, true);
    }

    private void BindData(int ID)
    {
        var COLLATERALMANUAL = new COLLATERALMANUAL();
        DataTable dtCOLLATERALMANUAL = COLLATERALMANUAL.SEARCH_BYID(ID);
        List<CollateralManual> CollateralManual = new List<CollateralManual>();
        ConvertHelper.ConvertDataTableToObject(dtCOLLATERALMANUAL, CollateralManual);
        if (dtCOLLATERALMANUAL.Rows.Count > 0)
        {
            //txtDATE_TRANSACTION.Text = CollateralManual[0].TransactionDate.Value.ToString("dd/MM/yyyy");
            txtDATE_TRANSACTION.Text = CollateralManual[0].TransactionDate.DateToString();

            if (CollateralManual[0].SourceDataID.ToString() != "")
                ddlSourceData.SelectedValue = CollateralManual[0].SourceDataID.ToString();

            txtAccountNo.Text = CollateralManual[0].AccountNo;

            if (CollateralManual[0].CollateralTypeID.ToString() != "")
            {
                txtCollateralNumber.Text = CollateralManual[0].CollateralTypeNameTH.ToString();
            }

            txtAmount.Text = CollateralManual[0].CollateralValue.ToString();

        }
    }

    #endregion

}